package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo4 {
    public static void main(String[] args) {
        try(Connection connection = DBUtil.getConnection();
        ) {
            Statement statement = connection.createStatement();
            String sql = "SELECT id,name,salary,title " +
                    "FROM teacher";
            ResultSet re = statement.executeQuery(sql);
            while(re.next()){
                int id = re.getInt("id");
                String name = re.getString("name");
                int salary = re.getInt("salary");
                String title = re.getString("title");
                System.out.println(id+"\t"+name+"\t"+salary+"\t"+title);
            }

        } catch (SQLException e) {
           e.printStackTrace();
        }
    }
}
